package com.topvision.jack.camerasdk2.camera.presenter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.topvision.jack.camerasdk2.R;
import com.topvision.jack.camerasdk2.camera.PhotoLoaderTask;

import java.util.ArrayList;
import java.util.List;

import uk.co.senab.photoview.PhotoView;

/**
 * Created by Administrator on 2017/12/25.
 */

public class ShowPhotoPresenterImpl implements ShowPhotoPresenter {

    Context context;
    List<String> list;
    LayoutInflater inflater;
    List<View> views;

    public ShowPhotoPresenterImpl(Context context, List<String> list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
        views = new ArrayList<>();
    }


    @Override
    public List<View> getViewData(Context context, List<String> list) {
        views.clear();
        for (int i = 0; i < list.size(); i++) {
            View convertView = inflater.inflate(R.layout.activity_camera_show_photo_item, null);
            PhotoView photo_view = convertView
                    .findViewById(R.id.photo_view);
            photo_view.setZoomable(true);
            if (i == 0) {
                String filePath = list.get(i);
                //默认第一张图
                new PhotoLoaderTask(context, photo_view).execute(filePath);
            }
            views.add(convertView);
        }
        return views;
    }
}
